package com.hs.activation.common.result;
import com.hs.activation.common.result.Result;
import com.hs.activation.common.result.ResultCode;
import com.hs.activation.dataemum.LogType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class BaseController
{
/*  14 */   private Logger log = LoggerFactory.getLogger(com.hs.activation.common.result.BaseController.class);
/*     */   
/*     */   private void writeLog(String message, LogType type, Throwable obj) {
/*  17 */     switch (type.ordinal()) {
/*     */       
/*     */       case 1:
/*  20 */         this.log.info(message);
/*     */         break;
/*     */       case 2:
/*  23 */         this.log.warn(message);
/*     */         break;
/*     */       case 3:
/*  26 */         if (obj == null) {
/*  27 */           this.log.debug(message);
/*     */           break;
/*     */         } 
/*  30 */         this.log.debug(message, obj);
/*     */         break;
/*     */       case 4:
/*  33 */         if (obj == null) {
/*  34 */           this.log.error(message);
/*     */           break;
/*     */         } 
/*  37 */         this.log.error(message, obj);
/*     */         break;
/*     */     } 
/*     */   }
/*     */   
/*     */   protected void warn(String message, Throwable obj) {
/*  43 */     writeLog(message, LogType.Warn, obj);
/*     */   }
/*     */   protected void warn(String message) {
/*  46 */     writeLog(message, LogType.Warn, null);
/*     */   }
/*     */   protected void info(String message, Throwable obj) {
/*  49 */     writeLog(message, LogType.Info, obj);
/*     */   }
/*     */   protected void info(String message) {
/*  52 */     writeLog(message, LogType.Info, null);
/*     */   }
/*     */   protected void debug(String message, Throwable obj) {
/*  55 */     writeLog(message, LogType.Debug, obj);
/*     */   }
/*     */   protected void debug(String message) {
/*  58 */     writeLog(message, LogType.Debug, null);
/*     */   }
/*     */   protected void error(String message, Throwable obj) {
/*  61 */     writeLog(message, LogType.Error, obj);
/*     */   }
/*     */   protected void error(String message) {
/*  64 */     writeLog(message, LogType.Error, null);
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public Result ok(String msg, Object data) {
/*  74 */     Result result = new Result();
/*  75 */     result.setMessage(msg);
/*  76 */     result.setCode(Integer.valueOf(ResultCode.OK.code));
/*  77 */     result.setData(data);
/*  78 */     return result;
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public Result ok() {
/*  88 */     Result result = new Result();
/*  89 */     result.setMessage("成功");
/*  90 */     result.setCode(Integer.valueOf(ResultCode.OK.code));
/*  91 */     return result;
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public Result ok(Object data) {
/* 100 */     Result result = new Result();
/* 101 */     result.setMessage("成功");
/* 102 */     result.setCode(Integer.valueOf(ResultCode.OK.code));
/* 103 */     result.setData(data);
/* 104 */     return result;
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public Result validate() {
/* 113 */     return validate("字段验证失败");
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public Result validate(String msg) {
/* 122 */     Result result = new Result();
/* 123 */     result.setMessage(msg);
/* 124 */     result.setCode(Integer.valueOf(ResultCode.VALIDATE.code));
/* 125 */     return result;
/*     */   }
/*     */ 
/*     */   
/*     */   public Result fail() {
/* 130 */     return fail("操作失败");
/*     */   }
/*     */   
/*     */   public Result fail(String msg) {
/* 134 */     Result result = new Result();
/* 135 */     result.setMessage(msg);
/* 136 */     result.setCode(Integer.valueOf(ResultCode.Fail.code));
/* 137 */     return result;
/*     */   }
/*     */   
/*     */   public Result error(Exception ex) {
/* 141 */     return error("失败", ex);
/*     */   }
/*     */ 
/*     */   
/*     */   public Result error(String msg, Exception ex) {
/* 146 */     Result result = new Result();
/* 147 */     result.setMessage(msg);
/* 148 */     result.setCode(Integer.valueOf(ResultCode.ERROR.code));
/* 149 */     result.setData(ex);
/* 150 */     return result;
/*     */   }
/*     */ }


/* Location:              C:\Users\yzc\Desktop\新建文件夹 (3)\activation-0.0.16.jar!\BOOT-INF\classes\com\hs\activation\common\result\BaseController.class
 * Java compiler version: 16 (60.0)
 * JD-Core Version:       1.1.3
 */